package com.steak.order.execute;

import com.steak.common.domain.dataobject.tcc.Order;
import com.steak.common.result.Response;
import com.steak.order.client.AccountClient;
import com.steak.order.dao.OrderDao;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;

/**
 * @author 刘牌
 * @Title:
 * @date 2022/3/116:22
 */
@Component
@AllArgsConstructor
public class OrderExecute {

    final OrderDao orderDao;
    final AccountClient accountClient;

    public Response execute(Order order) {
        //保存订单信息
        orderDao.saveOrder(order);
        //扣减账户余额
        accountClient.decreaseBalance(order);
        return new Response(200,"placeOrder success",null);
    }
}
